<!-- 正文开始 -->
<form id="resumeForm" lay-filter="resumeForm" class="layui-form model-form"
      style="padding: 25px 30px 0 30px;">
    <div class="word" style="padding: 0 0 25px 0;">
        <style type="text/css">
            * {
                outline: none;
                list-style: none;
            }

            input {
                border: none;
                font-size: 16px;
            }

            textarea {
                border: none;
                width: 95%;
                height: 300px;
                font-size: 16px;
            }

            table {
                border-right: 1px solid black;
                border-bottom: 1px solid black;
                border-collapse: collapse;
            }

            table td {
                border-left: 1px solid black;
                border-top: 1px solid black;
                text-align: center;
            }

            table td {
                height: 35px;
            }

        </style>
        <table style="width: 100%; font-size: 16px; border: none;" align="center">
            <tr style="height: 30px;">
                <td colspan="8" style="border:none;text-align: center;font-weight: bold;font-size: 18px;">
                    <p> 火箭军士官学校个人档案表</p>
                    <p id="userTitle"></p>
                </td>
            </tr>
            <tr style="height: 30px;">
                <td style="width:50%; border-left: none; border-top: none;"></td>
                <td style="width:8%; border-left: none; border-top: none; font-weight: bold;">编号：</td>
                <td style="width:8%; border-left: none; border-top: none;" id="tableYear"></td>
                <td style="width:4%; border-left: none; border-top: none; font-weight: bold;">年</td>
                <td style="width:20%; border-left: none; border-top: none;" id="userId"></td>
                <td style="width:4%; border-left: none; border-top: none; font-weight: bold;">号</td>

            </tr>
        </table>
        <table style="width: 100%;clear:both; font-size: 16px;" align="center">
            <tr>
                <td colspan=2 style="font-weight: bold;">入职日期</td>
                <td colspan=2 name="enroltime" id="enroltime"></td>
                <td colspan=2 style="font-weight: bold;">入职单位</td>
                <td colspan=2 name="orgName" id="orgName"></td>
            </tr>
            <tr>
                <td colspan=2 style="font-weight: bold;">结业时间</td>
                <td colspan=2 id="graduationtime"></td>
                <td colspan=2 style="font-weight: bold;">担任岗位</td>
                <td colspan=2 id="posName"></td>
            </tr>
            <tr>
                <td colspan=8 style="font-weight: bold;">个人简况</td>
            </tr>
            <tr>
                <td style="width:15%; font-weight: bold;">姓名</td>
                <td style="width:10%" id="userName"></td>
                <td style="width:10%; font-weight: bold;">性别</td>
                <td style="width:10%" id="userSex"></td>
                <td style="width:10%; font-weight: bold;">民族</td>
                <td style="width:15%" id="userNation"></td>
                <td style="width:10%; font-weight: bold;">籍贯</td>
                <td style="width:15%" id="userNativePlace"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">政治面貌</td>
                <td colspan=3 id="userPoliticalOutlook"></td>
                <td colspan=1 style="font-weight: bold;">军衔</td>
                <td colspan=3 id="rank"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">学号</td>
                <td colspan=3 id="userStuNumber"></td>
                <td colspan=1 style="font-weight: bold;">专业</td>
                <td colspan=3 id="aftermajor"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">手机号</td>
                <td colspan=3 id="userPhone"></td>
                <td colspan=1 style="font-weight: bold;">出生年月</td>
                <td colspan=3 id="userBirthday"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">学历</td>
                <td colspan=3 id="education"></td>
                <td colspan=1 style="font-weight: bold;">入伍时间</td>
                <td colspan=3 id="joinUpTime"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">入学前单位</td>
                <td colspan=3 id="entryunit"></td>
                <td colspan=1 style="font-weight: bold;">培训层次</td>
                <td colspan=3 id="leveltrain"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">身份证号</td>
                <td colspan=7 id="userIdNumber"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">立功授奖</td>
                <td colspan=7 id="userMer"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">活动经历</td>
                <td colspan=7 id="userActivity"></td>
            </tr>
            <tr>
                <td colspan=1 style="font-weight: bold;">学习经历</td>
                <td colspan=7 id="userStudy"></td>
            </tr>
           <!-- <tr>
                <td colspan=1 style="font-weight: bold;">学习训练成绩</td>
                <td colspan=7 id="userStudyScore"></td>
            </tr>-->
            <tr>
                <td colspan=1 style="font-weight: bold;">工作经历</td>
                <td colspan=7 id="userJob"></td>
            </tr>
        </table>
    </div>

    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" id="formBackBtn" ew-event="closeDialog">取消
        </button>
        <button class="layui-btn" lay-filter="formSubmitBtn" id="resumeBtn" lay-submit>导出</button>
    </div>
</form>
<!-- js部分 -->
<script src="${ctxPath}/assets/libs/wordExport/jquery-3.4.1.js"></script>
<script src="${ctxPath}/assets/libs/wordExport/FileSaver.js"></script>
<script src="${ctxPath}/assets/libs/wordExport/jquery.wordExport.js"></script>
<script>
    layui.use(['layer', 'form', 'admin', 'xnUtil', 'xmSelect', 'laydate'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var admin = layui.admin;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#activityTimeId'
        });

        var editData = admin.getLayerData('#resumeForm').data;
        $("#enroltime").html(editData.enroltime);
        $("#graduationtime").html(editData.graduationtime);
        $("#rank").html(editData.rank);
        $("#aftermajor").html(editData.aftermajor);
        $("#entryunit").html(editData.entryunit);
        $("#leveltrain").html(editData.leveltrain);
        $("#userTitle").html(editData.name);

        debugger;
        if (editData !== null && editData !== undefined) {
            admin.req(getProjectUrl() + 'sysUser/detail?id=' + editData.id, function (res) {
                console.log(res)
                $("#tableYear").html(new Date().getFullYear());// 编号(年)
                $("#userId").html(res.data.id);// 编号(id)
                // $("#entryDay").html(res.data.entryDay);// 入职日期
                $("#orgName").html(res.data.sysEmpInfo.orgName);// 入职部门
                $("#posName").html(res.data.sysEmpInfo.positions.map(function (item) {
                    return item.posName + "\t";
                }));// 担任职位
                $("#userName").html(res.data.name);// 姓名
                var userSex = "";
                switch (res.data.sex){
                    case 1:
                        userSex = "男性"
                        break;
                    case 2:
                        userSex = "女性"
                        break;
                    case 3:
                        userSex = "未知"
                        break
                }
                $("#userSex").html(userSex);// 性别
                $("#userNation").html(res.data.nation);// 民族
                $("#userNativePlace").html(res.data.nativePlace);// 籍贯
                $("#userPoliticalOutlook").html(res.data.politicalOutlook);// 政治面貌
                $("#userBirthday").html(res.data.birthday);// 出生年月
                $("#userSchool").html(res.data.school);// 学校
                // $("#userSpeciality").html(res.data.speciality);// 专业
                $("#userPhone").html(res.data.phone);// 手机号
                $("#userStuNumber").html(res.data.stuNumber);// 学号
                $("#userIdNumber").html(res.data.idNumber);// 身份证号
                $("#education").html(res.data.education);// 学历
                $("#joinUpTime").html(res.data.rwtime);// 入伍时间
                $.ajax({
                    url: getProjectUrl() + 'sysUserActivity/page?userId=' + res.data.id,
                    type:'GET',
                    dataType:'json',
                    success:function(msg){
                        let str="";
                        for(let i = 0; i < msg.data.length;i++){
                            str += msg.data[i].activityTime + "&nbsp&nbsp&nbsp&nbsp"+msg.data[i].activityTitle +"<br>";
                        }
                        $("#userActivity").html(str);// 活动经历
                        $("#userActivity").parent().attr("rowspan",msg.data.length);
                    },
                    error:function(err){
                        console.error(err);
                    }
                })
                $.ajax({
                    url: getProjectUrl() + 'sysUserStudyExperience/page' + '?userId=' + res.data.id,
                    type:'GET',
                    dataType:'json',
                    success:function(msg){
                        let str="";
                        for(let i = 0; i < msg.data.length;i++){
                            str += msg.data[i].studyTime + "&nbsp&nbsp&nbsp&nbsp"+msg.data[i].studyTitle + "<br>";
                        }
                        $("#userStudy").html(str);// 学习经历
                        $("#userStudy").parent().attr("rowspan",msg.data.length);
                    },
                    error:function(err){
                        console.error(err);
                    }
                })
                $.ajax({
                    url: getProjectUrl() + 'sysUserJobExperience/page' + '?userId=' + res.data.id,
                    type:'GET',
                    dataType:'json',
                    success:function(msg){
                        debugger;
                        let str="";
                        for(let i = 0; i < msg.data.length;i++){
                            str += msg.data[i].jobTime + "-"+msg.data[i].endTime+"&nbsp&nbsp&nbsp&nbsp"+msg.data[i].jobTitle +"<br>";
                        }
                        $("#userJob").html(str);// 工作经历
                        $("#userJob").parent().attr("rowspan",msg.data.length);
                    },
                    error:function(err){
                        console.error(err);
                    }
                })
                console.log(res.data.id)
                $.ajax({
                    url: getProjectUrl() + 'sysUserMer/page' + '?userId=' + res.data.id,
                    type:'GET',
                    dataType:'json',
                    success:function(msg){
                        console.log(msg)
                        let str="";
                        for(let i = 0; i < msg.data.length;i++){
                            str += msg.data[i].merTime.slice(0,11) + "&nbsp&nbsp&nbsp&nbsp"+msg.data[i].merTitle + "<br>";
                        }
                        $("#userMer").html(str);// 立功经历
                        $("#userMer").parent().attr("rowspan",msg.data.length);
                    },
                    error:function(err){
                        console.error(err);
                    }
                })
                $.ajax({
                    url: getProjectUrl() + 'sysUserStuScore/page' + '?userId=' + res.data.id,
                    type:'GET',
                    dataType:'json',
                    success:function(msg){
                        console.log(msg)
                        let str="";
                        for(let i = 0; i < msg.data.length;i++){
                            console.log(i%3)
                            if(i == 2 || (i % 3 ==0 && i != 0)){
                                str += msg.data[i].name + ": " + msg.data[i].score   + "<br>";
                            }else{
                                str += msg.data[i].name + ": " + msg.data[i].score + "&nbsp&nbsp&nbsp&nbsp";
                            }
                        }
                        $("#userStudyScore").html(str);// 学习培训成绩
                        // $("#userMer").parent().attr("rowspan",msg.data.length);
                    },
                    error:function(err){
                        console.error(err);
                    }
                })
                // $("#userMer").html();//立功经历
                // $("#userActivity").html();// 活动经历
                // $("#userStudy").html();// 学习经历
                // $("#userStudyScore").html();// 学习训练成绩
                // $("#userJob").html();// 工作经历
            });
        }


        $("#resumeBtn").click(function (event) {
            var data = {
                fileName: "测试文档",//文档名
                fileType: ".doc",//文档类型  经测试  可以doc xls html 其他的自己去试
                isHeader: false,//是否显示页眉  *xls  不要设置页眉页脚  改为false
                isFooter: false,//是否显示页脚  *xls  不要设置页眉页脚  改为false
                // header: "测试页眉",//页眉标题
                styles: $("#wordExPortCss"),//要导出的内容style
                updateExportCss: $("#updateExportCss")//需要修改导出的word样式  宽度高度 margin之类的
            }
            $(".word").wordExport(data);
        });

    });
</script>
</body>
</html>
